package com.ti.winona.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则表达式使, 公共类
 * 
 * @author kTian
 */
public class RegexUtil {
	
	// 提出Http连接
	public static String parseUrl(String content){
		String rex = "((http[s]{0,1}|ftp)://[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&*+?:_/=<>]*)?)|(www.[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&*+?:_/=<>]*)?)";
		Pattern pattern = Pattern.compile(rex);
        Matcher matcher = pattern.matcher(content);
        StringBuffer buffer = new StringBuffer();
        while(matcher.find()){              
            buffer.append(matcher.group());       
            buffer.append("\r\n");             
        }   
        System.out.println(buffer.toString());
        return buffer.toString();
	}

}
